﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using App.Interface;
using App.Model;
using App.Model.MoBanModel;
using Newtonsoft.Json;

namespace App.Realization
{
    public class MoBantmpl : IMoBan
    {
        public void AddMoBan(string str)
        {
            var reslut = HttpClientHelper.PostResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/SaveGZJH", str);
        }

        public void AddJiXiaoMoBan(string str)
        {
            var reslut = HttpClientHelper.PostResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/SaveJX", str);
        }

        public string GetGZJHList()
        {
            var result = HttpClientHelper.GetResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/GetGZJHMB");
            return result;
        }

        public string GetJXList()
        {
            var result = HttpClientHelper.GetResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/GetJiXiaos");
            return result;
        }

        public void DelGZJH(int mbid)
        {
            var result = HttpClientHelper.GetResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/DelMoBan?mbid=" + mbid + "&mblx=1");
        }

        public void DelJX(int mbid)
        {
            var result = HttpClientHelper.GetResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/DelMoBan?mbid=" + mbid + "&mblx=2");
        }

        public string GetMoBanKaoHeFanWei(int nrid, string username)
        {
            var result = HttpClientHelper.GetResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/GetMoBanKaoHeFanWei?nrid=" + nrid + "&username=" + username);
            return result;
        }

        public string GetGZJHInfo(int mbid)
        {
            var result = HttpClientHelper.GetResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/GetGongZuoJiHuaInfo?mbid=" + mbid);
            return result;
        }

        public void AddKaoHeFanWei(int nrid, int zwid, string username)
        {
            var result = HttpClientHelper.GetResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/AddKaoHeFanWei?nrid=" + nrid + "&zwid=" + zwid + "&username=" + username);

        }

        public void DelKaoHeFanWei(int nrid, string zwids, string username)
        {
            var result = HttpClientHelper.GetResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/DelKaoHeFanWei?nrid=" + nrid + "&zwids=" + zwids + "&username=" + username);
        }

        public string GetJXInfo(int mbid)
        {
            var result = HttpClientHelper.GetResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/GetJiXiaoInfo?mbid=" + mbid);
            return result;
        }

        public void CreateKaoHeBiao(int ksid, string username, string datetimes)
        {
            var result = HttpClientHelper.GetResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/PingShen/CreateWanZhongKaoHeBiao?ksid=" + ksid + "&username=" + username + "&datetimes=" + datetimes);
        }

        public void ReviewKaoHeBiao(int ksid, string username)
        {
            var result = HttpClientHelper.GetResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/PingShen/ReviewKaoHeBiao?ksid=" + ksid + "&username=" + username);
        }

        public void AddKaoHeFanWeiRenYuan(int nrid, string ry, string username)
        {
            var result = HttpClientHelper.GetResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/AddKaoHeFanWeiRenYuan?nrid=" + nrid + "&ry=" + ry + "&username=" + username); ;
        }

        public string GetMoBanKaoHeFanWeiRenYuan(int nrid, string username)
        {
            var result = HttpClientHelper.GetResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/GetMoBanKaoHeFanWeiRenYuan?nrid=" + nrid + "&username=" + username);
            return result;
        }

        public string GetMoBanList()
        {
            var result = HttpClientHelper.PostResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/GetAllMoBan", "");
            return result;
        }

        public string GetControlList()
        {
            var result = HttpClientHelper.GetResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/GetControlAll");
            return result;
        }

        public string GetSearchMoBanList(string keyword)
        {
            dynamic a = new { keyword = keyword };
            var postData = JsonConvert.SerializeObject(a);
            var result = HttpClientHelper.PostResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/GetSearchMoBanList", postData);
            return result;
        }

        public string GetMoBanType()
        {
            var result = HttpClientHelper.GetResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/GetMoBanType");
            return result;
        }

        public void SaveMoBan_Main(MoBan_Main mb, string cjrid)
        {
            dynamic a = new { name = mb.mbmc, cjrid = cjrid, mbtype = (int)mb.mbtype };
            var postData = JsonConvert.SerializeObject(a);
            var result = HttpClientHelper.PostResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/AddMoBan", postData);
        }

        public void DelMoBan(int mbid)
        {
            var result = HttpClientHelper.GetResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/DelMoBanMain?mbid=" + mbid);
        }

        public string GetExceptMySelfMoBan(int mbid, string keyword)
        {
            dynamic a = new { mbid = mbid, keyword = keyword };
            var postData = JsonConvert.SerializeObject(a);
            var result = HttpClientHelper.PostResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/GetExceptMySelfMoBan", postData);
            return result;
        }

        public int PathAdd(MoBan_Path model, int mbid)
        {
            dynamic a = new { model = model, mbid = mbid };
            var postData = JsonConvert.SerializeObject(a);
            var result = HttpClientHelper.PostResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/AddMoBanPath", postData);
            return int.Parse(result.ToString());
        }
        public void PathUpdate(MoBan_Path model, int mbid)
        {

            dynamic a = new { model = model, mbid = mbid };
            var postData = JsonConvert.SerializeObject(a);
            var result = HttpClientHelper.PostResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/UpdateMoBanPath", postData);
        }


        public void ContentUpdate(MoBan_Content model, int mbid, int ljid)
        {
            dynamic a = new { model = model, ljid = ljid, mbid = mbid };
            var postData = JsonConvert.SerializeObject(a);
            var result = HttpClientHelper.PostResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/UpdateMoBanContent", postData);
        }

        public int ContentAdd(MoBan_Content model, int mbid, int ljid)
        {
            dynamic a = new { model = model, ljid = ljid, mbid = mbid };
            var postData = JsonConvert.SerializeObject(a);
            var result = HttpClientHelper.PostResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/AddMoBanContent", postData);
            return int.Parse(result.ToString());
        }

        public void AnswerUpdate(MoBan_Answer model, int mbid, int ljid, int nrid)
        {
            dynamic a = new { model = model, mbid = mbid, ljid = ljid, nrid = nrid };
            var postData = JsonConvert.SerializeObject(a);
            var result = HttpClientHelper.PostResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/UpdateMoBanAnswer", postData);
        }

        public int AnswerAdd(MoBan_Answer model, int mbid, int ljid, int nrid)
        {
            dynamic a = new { model = model, mbid = mbid, ljid = ljid, nrid = nrid };
            var postData = JsonConvert.SerializeObject(a);
            var result = HttpClientHelper.PostResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/AddMoBanAnswer", postData);
            return int.Parse(result.ToString());
        }

        public void PathDel(int mbid, int ljid)
        {
            var result = HttpClientHelper.GetResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/DelMoBanPath?mbid=" + mbid + "&ljid=" + ljid);
        }

        public void ContentDel(int mbid, int ljid, int nrid)
        {
            var result = HttpClientHelper.GetResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/DelMoBanContent?mbid=" + mbid + "&ljid=" + ljid + "&nrid=" + nrid);
        }

        public void AnswerDel(int mbid, int ljid, int nrid, int answerid)
        {
            var result = HttpClientHelper.GetResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/DeleteMoBanAnswer?mbid=" + mbid + "&ljid=" + ljid + "&nrid=" + nrid + "&answerid=" + answerid);
        }

        public string GetKaoHeFanWeis(string name)
        {
            var result = HttpClientHelper.GetResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/GetKaoHeFanWeis?name=" + name);
            return result;
        }

        public string GetKaoHeFanWei(int khfwryid)
        {
            var result = HttpClientHelper.GetResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/GetKaoHeFanWei?khfwryid=" + khfwryid);
            return result;
        }

        public int AddKaoHeFanWei(string userinfoid)
        {
            var result = HttpClientHelper.GetResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/AddKaoHeFanWei?userinfoid=" + userinfoid);
            return int.Parse(result);
        }

        public void AddKaoHePath(int khfwryid, int ljid)
        {
            var result = HttpClientHelper.GetResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/AddKaoHePath?khfwryid=" + khfwryid+ "&ljid="+ ljid);
        }

        public void DelKaoHePath(int khfwryid, int nrid)
        {
            var result = HttpClientHelper.GetResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/DelKaoHePath?khfwryid=" + khfwryid + "&nrid=" + nrid);
        }

        public void AddBeiKaoHeJiaoZhiGong(int khfwryid, string userid)
        {
            var result = HttpClientHelper.GetResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/AddBeiKaoHeJiaoZhiGong?khfwryid=" + khfwryid + "&userid=" + userid);
        }

        public void AddBeiKaoHeJiaoZhiGongKeShi(int khfwryid, int ksid)
        {
            var result = HttpClientHelper.GetResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/AddBeiKaoHeJiaoZhiGongKeShi?khfwryid=" + khfwryid + "&ksid=" + ksid);
        }

        public void DelBeiKaoHeJiaoZhiGong(int khfwryid, string userid)
        {
            var result = HttpClientHelper.GetResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/DelBeiKaoHeJiaoZhiGong?khfwryid=" + khfwryid + "&userid=" + userid);
        }

        public void DelKaoHeFanWei(int khfwryid)
        {
            var result = HttpClientHelper.GetResponse(System.Web.Configuration.WebConfigurationManager.AppSettings["schoolapi"] + "/api/MoBan/DelKaoHeFanWei?khfwryid=" + khfwryid);
        }
    }
}
